package com.pic.mgt.syushin.executer.bucket;

import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

import com.pic.mgt.HaishinLauncher;
import com.pic.mgt.log.IgxLog;
import com.pic.mgt.syushin.SyushinScheduler;

public class SyushinBucketExecutionQuartzJobBean extends QuartzJobBean {
	
	private static SyushinBucketProcess syushinBucketProcess;
	
	static {
		syushinBucketProcess = 
			HaishinLauncher.applicationContext.getBean(
									"simpleSyushinBucketProcess",
									SimpleSyushinBucketProcess.class);
	}

	@Override
	protected void executeInternal(JobExecutionContext jobExecutionContext)
											throws JobExecutionException {
		JobDataMap jobDataMap = 
			jobExecutionContext.getTrigger().getJobDataMap();
		String businessName =
			(String)jobDataMap.get(SyushinScheduler.JOB_DATA_BUSINESS_NNAME_KEY);
		
		// ********************** Log **********************
		if (IgxLog.messageLog.isDebugMode()) {
		IgxLog.messageLog.debug(this,
				"Quartz job: Sending syushin bucket business '{}' execution  to syushin bucket proccesser.",
				businessName);
		}
	// ********************** Log **********************
	
		syushinBucketProcess.perform(businessName);
	}

}
